package com.vcg.community.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import vc.dubbo.result.DubboResult;

import com.vcg.community.common.base.BaseServiceImpl;
import com.vcg.community.dao.ExifMapper;
import com.vcg.community.dao.ResourceMapper;
import com.vcg.community.dao.TagMapper;
import com.vcg.community.model.BigResource;
import com.vcg.community.model.Exif;
import com.vcg.community.model.Resource;
import com.vcg.community.model.Tag;

public class ResourceGetServiceImpl extends BaseServiceImpl<Resource> implements ResourceGetService {

	@Autowired
	private ResourceMapper rsDao;

	@Autowired
	private ExifMapper efDao;

	@Autowired
	private TagMapper tgDao;

	public DubboResult<BigResource> doGetDetail(String strResourceId) {
		BigResource bigRS=new BigResource();
		// TODO Auto-generated method stub
		DubboResult resultObject=new DubboResult(200,"",null);
		try{
			Resource rs=rsDao.selectByResourceID(strResourceId);
			bigRS.setResource(rs);
			Exif exif=efDao.selectByResourceID(rs.getId());
			bigRS.setExif(exif);
			List<Tag> tagList=tgDao.selectTagByResourceId(rs.getId());
			bigRS.setTags(tagList);
			resultObject.setResult(bigRS);
		}catch(Exception ex){
			resultObject.setCode(521);
			resultObject.setCodeError(ex.toString());
			
		}
		return resultObject;
	}

	public DubboResult<Exif> doGetExif(String strResourceId) {
		// TODO Auto-generated method stub
		DubboResult resultObject=new DubboResult(200,"",null);
		try{
			resultObject.setResult(rsDao.selectByResourceID(strResourceId));
		}catch(Exception ex){
			resultObject.setCode(521);
			resultObject.setCodeError(ex.toString());
			
		}
		return resultObject;
	}

	
	@Override
	public void setDao() {
		// TODO Auto-generated method stub
		this.baseDao=rsDao;		
	}



}
